from PyQt5.QtWidgets import QApplication, QFileDialog
from translate import l


def new_project():
    app = QApplication([])
    filter_str = f"{l.ckp_name} (*.ckp)"
    file_path, _ = QFileDialog.getSaveFileName(
        None,
        l.new_project,
        "",
        filter_str,
        f"{l.ckp_name} (*.ckp)"
    )
    if file_path != "" and file_path.split(".")[-1] != "ckp":
        file_path = file_path+".ckp"
    app.quit()
    return file_path


def open_project():
    app = QApplication([])
    file_path = QFileDialog.getExistingDirectory(
        None,
        l.new_project
    )
    app.quit()
    return file_path


def open_song_file():
    app = QApplication([])
    filter_str = f"mp3 (*.mp3)"
    file_path, _ = QFileDialog.getOpenFileName(
        None,
        l.open_song_file,
        "",
        filter_str,
        f"mp3 (*.mp3)"
    )
    app.quit()
    return file_path


def open_cover_file():
    app = QApplication([])
    filter_str = f"png (*.png)"
    file_path, _ = QFileDialog.getOpenFileName(
        None,
        l.open_cover_file,
        "",
        filter_str,
        f"png (*.png)"
    )
    app.quit()
    return file_path
